package com.blacamdk.ChatNetModule;

import com.blacamdk.ChatSecret.Blowfish;

import java.io.UnsupportedEncodingException;
import java.util.regex.Pattern;

/**
 * Utils
 *
 * @author BlacAmDK
 * @date 16-12-20
 */
public class Utils {

    static Blowfish blowfish = new Blowfish();
    enum ERR_TYPE{
        OK, WRONG_PASSWORD, USERNAME_EXIST, USERNAME_NOT_EXIST, FAILED_TOO_MANY, FAILED, WRONG_KEY, OTHER
    }
    public static boolean isNumeric(String str){
        Pattern pattern = Pattern.compile("[0-9]*");
        return pattern.matcher(str).matches();
    }
    public synchronized  static String[] Analyze(String s)
    {
        System.out.println(s);
        String[] ret = null;
        ret = s.split(" ");
        System.out.println(ret[1]);
        if(!isNumeric(ret[0]))
            return null;
        return ret;
    }
    public static int addbyte(byte[] dst, byte[] src, int pos)
    {
        if(pos + src.length > 60000)
            return pos;
        System.arraycopy(src, 0, dst, pos, src.length);
        return pos + src.length;
    }
}
